<?PHP

/**
 * 系统结构核心数据传输类
 *
 * 定义核心方法;
 * 统一的派生方法:包括数据传输类初始化和常用操作
 *
 * @author     Robot
 * @version    1.0
 * @package    Base Framework
 * @access     public
 * @copyright  商业软件,受著作权保护
 * @link       http://***
 */

abstract class InitDTO
{
	/**
	 * 类名称
	 *
	 * @var    string
	 * @access public
	 */
	public $childClass = "InitDTO";
	
	/**
	 * 数据验证开关: Y验证；N不验证
	 *
	 * @var    enum('Y','N')
	 * @access public
	 */
	public $_check = 'N';
	
	/**
	 * 构造函数
	 *
	 * @access public
	 * @param  void
	 * @return void
	 */
	public function __construct($aPOST, $childClass)
	{
		$this->childClass = $childClass;
		#$this->loadFunc("funcCheck");
		if(is_array($aPOST))
		{
			$this->_check = "Y";
			foreach($aPOST as $key => $value)
			{
				$this->__set($key, $value);
			}
		}
	}
	
	/**
	 * 属性重载
	 *
	 * @access public
	 * @param  string $property 属性
	 * @param  string $value 属性值
	 * @return void
	 */
	public function __set($property, $value)
	{
		if($this->_check == "N")
		{
			//Fixed bug property_exists at php version 5.2.4
			$property = "_" . $property;
			if(property_exists($this->childClass, $property))
			{
				$this->$property = $value;
			}
			else
			{
				return false;
			}
		}
		else
		{
			$method = "set" . ucfirst($property);
			if(method_exists($this->childClass, $method))
			{
				$this->$method($value);
			}
			else
			{
				return false;
			}
		}
	}
	
	/**
	 * 属性重载
	 *
	 * @access public
	 * @param  string $property 属性
	 * @return void
	 */
	public function __get($property)
	{
		$method = "get" . ucfirst($property);
		if(method_exists($this->childClass, $method))
		{
			return $this->$method();
		}
		else
		{
			if(property_exists($this->childClass, $property))
			{
				return $this->$property;
			}
			else
			{
				return false;
			}
		}
	}
}
//-------------------------------------------------------------------
//end class
?>